import java.util.*;
import java.math.*;

public class CalSolver {

	public static void main(String[] args) 
			throws BracketDismatch, OperatorDismatch,LimitDiffuse,VariableDismatch {
		
		double ans;
		String equ = "1/n";
		ans = ArithProgSolver.limitGener(equ);
		System.out.println(ans);
	}
	
	static double EPS = 1E-4; //using a tiny  number as infinitely small
	static double INF = 1E8;  //using a large number as infinitely great'
	static int    ITER_LIMIT = 1000; //The max time of iteration

}

/*interface Expr {
	static double  eval(String equ);
}

interface Func {
	static double static fx(String equ,double x);
	static double fx(String equ,String var, double[] val);
	static double diff(String equ,String var,double[] val,int order);
	static double integral(String equ,double lower,double upper);
	static double limit(String equ,double x);
}

interface ArithProg { // arithmetic progression, index from 1
	static double atGener(String equ,int index);
	static double sumGener(String equ,int lower, int upper); //[lower,upper]
	static double lmitGener(String equ);
	static double atRecur(String equ,double[] val,int index);
	static double sumRecur(String equ,double[] val,int lower, int upper);
	static double limitrecur(String equ,double[] val);
}*/

class BracketDismatch extends Throwable {
	static final long serialVersionUID = 1L;
}

class OperatorDismatch extends Throwable {
	static final long serialVersionUID = 1L;
}

class LimitDiffuse extends Throwable {
	static final long serialVersionUID = 1L;
}

class VariableDismatch extends Throwable {
	int varNum;
	int valNum;
	static final long serialVersionUID = 1L;
}


class ExprSolver  {
	static Set<Character> operatorType;
	
	static {
		//initialize static Set operatorType
		operatorType = new HashSet<Character>();
		operatorType.add('s');	//sin
		operatorType.add('c');	//cos
		operatorType.add('t');	//tan
		operatorType.add('S');	//arcsin
		operatorType.add('C');	//arccos
		operatorType.add('T');	//arctan
		operatorType.add('i');	//sinh
		operatorType.add('o');	//cosh
		operatorType.add('a');	//tanh
		operatorType.add('p');	//exp
		operatorType.add('n');	//ln
		operatorType.add('g');	//lg
		operatorType.add('^');	//power
		operatorType.add('*');
		operatorType.add('/');
		operatorType.add('+');
		operatorType.add('-');
	}
	
	protected static String pretreat(String equ) {
		// replace function for an expression with two operands.
		equ = equ.replace("sin","1s");
		equ = equ.replace("cos","1c");
		equ = equ.replace("tan","1t");
		equ = equ.replace("asin","1S");
		equ = equ.replace("acos","1C");
		equ = equ.replace("atan","1T");
		equ = equ.replace("sinh","1i");
		equ = equ.replace("cosh","1o");
		equ = equ.replace("tanh","1a");
		equ = equ.replace("exp","1p");
		equ = equ.replace("ln","1n");
		equ = equ.replace("log","1g");
		return equ;
	}
	 
	protected static double calPoly(String equ)
			throws BracketDismatch,OperatorDismatch {
		
		List<Character> operQueue = new ArrayList<Character>();
		List<Double> valQueue = new ArrayList<Double>();
		int iter, beg = 0;
		String temp = new String();
		
		BracketDismatch bracketDismatch = new BracketDismatch();
		for (iter = 0;iter < equ.length();iter++) {
			if (equ.indexOf(iter) == '(' || equ.indexOf(iter) == ')' ) {
				throw bracketDismatch;
			}
			//if equ[iter] is a operator push it into operQueue
			if ( operatorType.contains( equ.charAt(iter) ) ) {
				//push the operator into operQueue
				operQueue.add(equ.charAt(iter));
				//get the left operand
				temp = equ.substring(beg,iter); //[temp,iter)
				valQueue.add(Double.valueOf(temp));
				beg = ++iter;
				 //If there is a negative sign, it will regard it as part of the value
	            //without judging whether it is an operator.
			}
		}
		//push the last val
		temp = equ.substring(beg,equ.length());
		valQueue.add(Double.valueOf(temp));
		// Calculate an expression and replace it with its answer.
	    // The operator, oper_que[i], has two operands, val_que[i] and val_que[i+1].
	    //calculate
		for (iter = 0;iter < operQueue.size();iter++) {
			if (operQueue.get(iter) == 's')  { //sin
				valQueue.set(iter+1, Math.sin(valQueue.get(iter + 1)) );
				valQueue.remove(iter);
				operQueue.remove(iter);
			}
			else if (operQueue.get(iter) == 'c')  { //cos
				valQueue.set(iter+1, Math.cos(valQueue.get(iter + 1)) );
				valQueue.remove(iter);
				operQueue.remove(iter);
			}
			else if (operQueue.get(iter) == 't')  { //cos
				valQueue.set(iter+1, Math.tan(valQueue.get(iter + 1)) );
				valQueue.remove(iter);
				operQueue.remove(iter);
			}
			else if (operQueue.get(iter) == 'S')  { //cos
				valQueue.set(iter+1, Math.asin(valQueue.get(iter + 1)) );
				valQueue.remove(iter);
				operQueue.remove(iter);
			}
			else if (operQueue.get(iter) == 'C')  { //cos
				valQueue.set(iter+1, Math.acos(valQueue.get(iter + 1)) );
				valQueue.remove(iter);
				operQueue.remove(iter);
			}
			else if (operQueue.get(iter) == 'T')  { //cos
				valQueue.set(iter+1, Math.atan(valQueue.get(iter + 1)) );
				valQueue.remove(iter);
				operQueue.remove(iter);
			}
			else if (operQueue.get(iter) == 'i')  { //cos
				valQueue.set(iter+1, Math.sinh(valQueue.get(iter + 1)) );
				valQueue.remove(iter);
				operQueue.remove(iter);
			}
			else if (operQueue.get(iter) == 'o')  { //cos
				valQueue.set(iter+1, Math.cosh(valQueue.get(iter + 1)) );
				valQueue.remove(iter);
				operQueue.remove(iter);
			}
			else if (operQueue.get(iter) == 'a')  { //cos
				valQueue.set(iter+1, Math.tanh(valQueue.get(iter + 1)) );
				valQueue.remove(iter);
				operQueue.remove(iter);
			}
			else if (operQueue.get(iter) == 'p')  { //cos
				valQueue.set(iter+1, Math.exp(valQueue.get(iter + 1)) );
				valQueue.remove(iter);
				operQueue.remove(iter);
			}
			else if (operQueue.get(iter) == 'n')  { //cos
				valQueue.set(iter+1, Math.log(valQueue.get(iter + 1)) );
				valQueue.remove(iter);
				operQueue.remove(iter);
			}
			else if (operQueue.get(iter) == 'g')  { //cos
				valQueue.set(iter+1, Math.log10(valQueue.get(iter + 1)) );
				valQueue.remove(iter);
				operQueue.remove(iter);
			}
		}
		for (iter = 0;iter < operQueue.size();iter++) {
			if (operQueue.get(iter) == '^')  { 
				valQueue.set(iter+1, Math.pow(valQueue.get(iter), valQueue.get(iter + 1)) );
				valQueue.remove(iter);
				operQueue.remove(iter);
			}
		}
		for (iter = 0;iter < operQueue.size();iter++) {
			if (operQueue.get(iter) == '*')  { 
				valQueue.set(iter+1, valQueue.get(iter)*valQueue.get(iter + 1) );
				valQueue.remove(iter);
				operQueue.remove(iter);
			}
			else if (operQueue.get(iter) == '/')  { 
				valQueue.set(iter+1, valQueue.get(iter)/valQueue.get(iter + 1) );
				valQueue.remove(iter);
				operQueue.remove(iter);
			}
		}
		for (iter = 0;iter < operQueue.size();iter++) {
			if (operQueue.get(iter) == '+')  { 
				valQueue.set(iter+1, valQueue.get(iter)+valQueue.get(iter + 1) );
				valQueue.remove(iter);
				operQueue.remove(iter);
			}
			else if (operQueue.get(iter) == '-')  { 
				valQueue.set(iter+1, valQueue.get(iter)-valQueue.get(iter + 1) );
				valQueue.remove(iter);
				operQueue.remove(iter);
			}
		}
		return valQueue.get(0);
	}
	
	protected static double calBracket(String equ) 
			throws OperatorDismatch,BracketDismatch{
		int iter;
		double ans;
		String temp = new String();
		String equTemp = new String();
		List<Integer> bracStack = new ArrayList<Integer>(); //the indexs of '('
		BracketDismatch bracketDismatch = new BracketDismatch();
		equ = ExprSolver.pretreat(equ);
		for (iter = 0;iter < equ.length();iter++) {
			if (equ.charAt(iter) == '(') {
				bracStack.add(iter);
			}
			else if (equ.charAt(iter) == ')') {
				 // calculate the expression within a pair of brackets
				temp = equ.substring(bracStack.get( bracStack.size()-1 ) +1, iter);
				ans = ExprSolver.calPoly(temp);
				//cast the ans (double) to string
				temp = String.valueOf(ans);
				//replace the brackets for its value
				equTemp = equ.substring(0, bracStack.get(bracStack.size() -1 ) ) + temp 
							+ equ.substring(iter + 1);
				equ = equTemp;
				bracStack.remove(bracStack.size() - 1);
			}
		}
		if (bracStack.isEmpty() == false) {
			throw bracketDismatch;
		}
		//calculate the last expression which has no bracket.
		return ExprSolver.calPoly(equ);
	}
	
	public static double eval(String equ) {
		double ans;
		String equCopy = equ;
		try {
			ans = ExprSolver.calBracket(equCopy);
		}
		catch (BracketDismatch e){
			System.out.println
			( "error: Brackets dismatch. Please check your input.");
			return -1;
		}
		catch (OperatorDismatch e) {
			System.out.println
			("error: Operators or Operands dismatch. Please check your input.");
			return -1;
		}
		finally {}
		return ans;
	}
}


class FuncSolver {
	
	 public static double fx(String equ, double x) {
		String temp = String.valueOf(x);
		String equCopy = equ.replace("x",temp);
		return ExprSolver.eval(equCopy);
	}
	
	protected static String subs(String equ,String[] var,double[] val) 
			throws VariableDismatch {
		
		int iter;
		String temp = new String();
		VariableDismatch variableDismatch = new VariableDismatch();
		if (var.length != val.length) {
			variableDismatch.valNum = val.length;
			variableDismatch.varNum = var.length;
			throw variableDismatch;
		}
		for (iter = 0; iter < var.length;iter++) {
			temp = String.valueOf(val[iter]);
			equ = equ.replace(var[iter], temp);
		}
		return equ;
	}
	
	public static double fx(String equ,String[] var,double[] val)
			throws VariableDismatch {
		String equCopy = equ;
		equCopy = FuncSolver.subs(equCopy, var, val);
		return ExprSolver.eval(equCopy);
	}
	
	protected static double limitFx(String equ, double x) 
		throws LimitDiffuse {
		double fa,fb,d;
		LimitDiffuse limitDiffuse = new LimitDiffuse();
		fa = FuncSolver.fx(equ, x - CalSolver.EPS);
		fb = FuncSolver.fx(equ, x + CalSolver.EPS);
		d = (fa>fb)?(fa-fb):(fb -fa);
		if (d < CalSolver.EPS ) {
	        return fb;
	    }
	    else {
	        throw limitDiffuse;
	    }
		
	}
	
	public static double limit(String equ, double x) {
	    double ans;
		try {
	       ans = limitFx(equ,x);
	    }
	    catch (LimitDiffuse e){
	       System.out.println("Limit diffuse.");
	       return -1;
	    }
	    finally {}
		return ans;
	}
	
	protected static double diff2Points(String equ, double x, int order) {
		double y1,y2;
		double ans = 0;
		if (order == 0) {
			ans = FuncSolver.fx(equ, x);
		}
		else if (order == 1) {
			y1  = FuncSolver.fx(equ, x);
			y2  = FuncSolver.fx(equ, x + CalSolver.EPS);
			ans = (y2 - y1 )/ CalSolver.EPS;
		}
		else if (order > 1) {
			y1 = FuncSolver.diff2Points(equ, x, order - 1);
			y2 = FuncSolver.diff2Points(equ, x + CalSolver.EPS, order - 1);
			ans = (y2 - y1)/ CalSolver.EPS;
		}
		return ans;
	}
	
	public static double diff(String equ, double x, int order) {
		return diff2Points(equ,x,order);
	}
	
	protected static double integralRomberg
								(String equ, double lower, double upper) {
		int i, k, m, n;
	    double h, x, s, p, q = 0, ep;
	    double[] y = new double[8];
	    h = upper - lower;
	    y[0] = h*(FuncSolver.fx(equ,lower) + FuncSolver.fx(equ,upper))/2.0;
	    m = 1;
	    n = 1;
	    ep = CalSolver.EPS + 1.0;
	    //iteration
	    while ((ep >= CalSolver.EPS) && (m < 8))
	    {
	        p = 0.0;
	        for (i=0; i<n; i++)
	        {
	            x = lower + (i+0.5)*h;
	            p = p + FuncSolver.fx(equ,x);
	        }
	        p = (y[0] + h*p)/2.0;
	        s = 1.0;
	        for (k=1; k<=m; k++)
	        {
	            s = 4.0*s;
	            q = (s*p - y[k-1])/(s - 1.0);
	            y[k-1] = p;
	            p = q;
	        }

	        p = Math.abs(q - y[m-1]);
	        m = m + 1;
	        y[m-1] = q;
	        n = n + n; h = h/2.0;
	    }
	    return q;
	}
	
	public static double integral(String equ, double lower, double upper) {
		return integralRomberg(equ,lower,upper);
	}
	
}

class ArithProgSolver {
	
	protected static double[] recur(String equ,double[] val,int valIter, int n)
		throws BracketDismatch,OperatorDismatch { // index from 0
		int iter,equIter,bracIter,offset;
		BracketDismatch bracketDismatch = new BracketDismatch();
		String equCopy,temp,index;
		double sum = 0; 
		for (; valIter <= n; valIter++ ){
			equCopy = equ;
			for (equIter = 0; equIter < equCopy.length(); equIter++) {
				if (equCopy.charAt(equIter) == 'a' || equCopy.charAt(equIter) == 's') {
					// get offset
					for (bracIter = equIter;
							equCopy.charAt(bracIter) != ']' && bracIter < equCopy.length(); bracIter++);
					if ( bracIter >= equCopy.length() ) {
						throw bracketDismatch;
					}
					temp = equCopy.substring(equIter+4,bracIter);
					offset = Integer.valueOf(temp);
					//get a[n - offset] or s[n - offset]
					if (equCopy.charAt(equIter) == 'a') {
						temp = String.valueOf(val[valIter - offset]);
					}
					else if (equCopy.charAt(equIter) == 's') {
						sum = 0;
						for (iter = 0;iter <= valIter - offset;iter++) {
							sum += val[iter];
						};
						temp = String.valueOf(sum);
					}
					index = equCopy.substring(equIter,bracIter+1);
					equCopy = equCopy.replace(index, temp);
				}
			}
			val[valIter] = ExprSolver.eval(equCopy);
		}
		return val;
	}
	
	public static double atRecur(String equ,double[] valArgu, int valIter, int n) 
			throws BracketDismatch,OperatorDismatch {
		
		int iter;
		double[] val = new double[n+2];
		double[] ans;
		for (iter = 0;iter < valIter; iter++) {
			val[iter] = valArgu[iter];
		}
		ans = recur(equ,val,valIter,n-1);
		return ans[n-1];
	}
	
	public static double sumRecur(String equ, double[] valArgu,int valIter, int lower, int upper) 
			throws BracketDismatch,OperatorDismatch  {
		int iter;
		double sum = 0;
		double[] val = new double[upper + 2];
		for (iter = 0; iter < valIter; iter++) {
			val[iter] = valArgu[iter];
		}
		val = ArithProgSolver.recur(equ, val, valIter, upper);
		for (iter = lower -1; iter < upper; iter++) {
			sum += val[iter];
		}
		return sum;
	}
	
	public static double limitRecur(String equ, double[] valArgu,int valIter) 
			throws BracketDismatch,OperatorDismatch,LimitDiffuse{
		
		double y,z,d;
		double[] val = new double[CalSolver.ITER_LIMIT + 2];
		int iter;
		LimitDiffuse limitDiffuse = new LimitDiffuse();
		for (iter = 0; iter < valIter; iter++) {
			val[iter] = valArgu[iter];
		}
		val = ArithProgSolver.recur(equ, val, valIter, CalSolver.ITER_LIMIT);
		y = val[CalSolver.ITER_LIMIT];
		z = val[CalSolver.ITER_LIMIT - 1];
		d = (y>z)?(y-z):(z-y);
		if (d < CalSolver.EPS) {
			return y;
		}
		else {
			throw limitDiffuse;
		}
	}
	
	public static double atGener(String equ, int n){
		String equCopy;
		equCopy = equ.replace("n", "x");
		return FuncSolver.fx(equCopy, n);
	}
	
	public static double sumGener(String equ, int lower, int upper) {//[lower,upper]
		double sum = 0;
		int iter;
		for (iter = lower; iter <= upper; iter++) {
			sum += FuncSolver.fx(equ, iter);
		}
		return sum;
	}
	
	public static double limitGener(String equ) 
			throws BracketDismatch,OperatorDismatch,LimitDiffuse{
		
		double y,z,d;
		LimitDiffuse limitDiffuse = new LimitDiffuse();
		y = atGener(equ,CalSolver.ITER_LIMIT);
		z = atGener(equ,CalSolver.ITER_LIMIT - 1);
		d = (y>z)?(y-z):(z-y);
		if (d < CalSolver.EPS) {
			return y;
		}
		else {
			throw limitDiffuse;
		}
	}
}




